<template>
  <div></div>
</template>

<script>
  import { getDeliveryType } from '@/api/shop'
  import { setDeliveryType } from '@/utils/auth'

  export default {
    data() {
      return {}
    },
    props: {
    },
    onShow() {
      this.getDeliveryTypeEls()
    },
    mounted() {
      setTimeout(() => {
        this.getDeliveryTypeEls()
      }, 100)
    },
    methods: {
      getDeliveryTypeEls() {
        let tabBtnList = []
        if (!this.getMemberId) return
        if (!this.getCustomerId) return
        getDeliveryType({memberId: this.getMemberId}).then(res => {
          let tempKeys = Object.keys(res.data).sort((a, b) => b - a)
          tempKeys.forEach(item => {
            tabBtnList.push({type: Number(item), text: res.data[item]})
          })
          setDeliveryType(tabBtnList)
          this.$emit('updateShoppingCart', tabBtnList)
        })
      }
    }
  }
</script>
